home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
106_01
/
stdio.doc
< prev
next >
Wrap
Text File
|
1980-07-08
|
4KB
|
71 lines
stdio.doc, an attempt to explain things.
The files that I've sent to the BDS C user's group include the
early versions of the code I used for simulating the UNIX facility
for invisible redirection of STDIN and STDOUT files. These
are not a finished product by any means, and you MUST understand
their operation to use them sucessfully!
A little history will help. The first version of stdio was written
before I had recieved the 1.32 (or 1.31+) version of the BDS
software, and before I decided to rewrite most of the I/O
functions. I have since been sidetracked and otherwise occupied,
so that neither of these interlocked projects is completed, and I
cannot honestly attempt to guess just when such completion may
occur. So. The files I sent are believed to be the final version
of the original effort, and will certainly suffice to demonstrate
the concept I used. BUT...I had a disk blowup and am not entirely
positive that the files I sent are the files that I was using!
So proceed with caution.
The primary thing to watch for when using these functions is...
The stdio routines need some static variables that can be accessed
by both stdopen and stdclose. In the BDS version of C, that means
they must be GLOBALS. This is a little bit messy, and there are
two approaches that could be used.
1) include the stdio functions and the global declarations
in the source of every program that uses them
2) include (as the VERY FIRST globals) the definitions of the
variables in each source file that will use the functions
I chose approach 2. The included file (in the early version) is
called "stdio.lib", and contains the declarations for the globals
needed by the stdopen and stdclose routines. This has the advantage
of letting the source for the stdio routines be compiled seperately
and put into a library. On the other hand, it also means that it is
YOUR resposibility to remember to include the definitions, because
the error will not be detected until the program blows up if you
forget.
I later incorporated the stdio declarations into my standard header
file (called "c.h"), which contains all sorts of standard definitions
that I use, which minimizes the possibility of forgetting them. But
I still had to re-compile quite a few programs before I felt I was
quite safe.
See also the documentation header in the stdio.src file.
To sum it all up: the files distributed are believed to be correct
working versions, and should behave properly. But there just might
be a symbol name or two that has gotten changed in one of the files
but not in another, or some other similar little glitch. So be sure
that you understand what's going on, and be careful.
If and when I complete the package, I'll send the whole mess to
our user's group. But I really can't say when that will happen,
which is the reason I submitted this interim version.
Good computing!
Marty Maney
postscript:
Since writing the above, I found an old listing of the stdio file.
It seems that the names of a few defined constants may have changed,
and I think that the default initialization of _stdin & _stdout
that is in the .src file may not be correct (for the stock versions
of getc & putc). Other than that, it looks like they're OK, but
I still think you should go over them before using them. It can't
hurt, and could prevent some anguish.